package com.lcb.manager.web;

import com.lcb.manager.configuration.Config;
import com.lcb.manager.entity.Chemical;
import com.lcb.manager.entity.Coal;
import com.lcb.manager.entity.Electricity;
import com.lcb.manager.repository.ChemicalRepository;
import com.lcb.manager.repository.CoalRepository;
import com.lcb.manager.repository.ElectricityRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value = "/product")
public class ProductController {

    @Autowired
    private CoalRepository coalRepository;

    @Autowired
    private ElectricityRepository electricityRepository;

    @Autowired
    private ChemicalRepository chemicalRepository;

    @RequestMapping(value = "/output_template")
    public String index(ModelMap model, @RequestParam int type) {
        switch (type) {
            case Config.coal:
                List<Coal> coalList = coalRepository.findAll();
                model.put("productList", coalList);
                break;
            case Config.electricity:
                model.put("type_name", "产电");
                model.put("factory_num", Config.electricity_factory_num);
                model.put("product_num", 0);
                break;
            case Config.chemical:
                model.put("type_name", "化工");
                model.put("factory_num", Config.chemical_factory_num);
                model.put("product_num", Config.chemical_product_num);
                break;
            default:
                break;
        }
        return "_add_output";
    }



}
